package com.ruoyi.web.controller.edh;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.edh.domain.EdhFinance;
import com.ruoyi.edh.domain.vo.EdhFinanceVo;
import com.ruoyi.edh.service.IEdhFinanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 易订货-财务结算Controller
 *
 * @author xxx
 * @date 2020-09-19
 */
@RestController
@RequestMapping("/edh/finance")
@Api(description = "易订货-财务结算")
public class EdhFinanceController extends BaseController {
    @Autowired
    private IEdhFinanceService edhFinanceService;

    /**
     * 查询易订货-财务结算列表
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:list')")
    @GetMapping("/list")
    @ApiOperation("易订货-财务结算列表")
    public TableDataInfo list(EdhFinanceVo edhFinanceVo) {
        startPage();
        List<EdhFinanceVo> list = edhFinanceService.selectEdhFinanceList(edhFinanceVo);
        return getDataTable(list);
    }

    /**
     * 导出易订货-财务结算列表
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:export')")
    @Log(title = "易订货-财务结算", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出易订货-财务结算列表")
    public AjaxResult export(EdhFinanceVo edhFinance) {
        List<EdhFinanceVo> list = edhFinanceService.selectEdhFinanceList(edhFinance);
        ExcelUtil<EdhFinanceVo> util = new ExcelUtil<EdhFinanceVo>(EdhFinanceVo.class);
        return util.exportExcel(list, "finance");
    }

    /**
     * 获取易订货-财务结算详细信息
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:query')")
    @GetMapping
    @ApiOperation("获取易订货-财务结算详细信息")
    public AjaxResult getInfo(Long id) {
        return AjaxResult.success(edhFinanceService.selectEdhFinanceById(id));
    }

    /**
     * 新增易订货-财务结算
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:add')")
    @Log(title = "易订货-财务结算", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增易订货-财务结算")
    public AjaxResult add(@RequestBody EdhFinance edhFinance) {
        return toAjax(edhFinanceService.insertEdhFinance(edhFinance));
    }

    /**
     * 修改易订货-财务结算
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:edit')")
    @Log(title = "易订货-财务结算", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改易订货-财务结算")
    public AjaxResult edit(@RequestBody EdhFinance edhFinance) {
        return toAjax(edhFinanceService.updateEdhFinance(edhFinance));
    }

    /**
     * 删除易订货-财务结算
     */
    @PreAuthorize("@ss.hasPermi('edh:finance:remove')")
    @Log(title = "易订货-财务结算", businessType = BusinessType.DELETE)
    @DeleteMapping
    @ApiOperation("删除易订货-财务结算")
    public AjaxResult remove(Long[] ids) {
        return toAjax(edhFinanceService.deleteEdhFinanceByIds(ids));
    }
}
